/* 
 * The base class, all its subclasses should implement <code>operator ()</code> to handle the syscalls of the source
 * binary code.
 */
#ifndef SIGNALREGISTER_H
#define SIGNALREGISTER_H

#include "crossbit/common.h"
//#include "crossbit/MemoryImage.h"
//#include "crossbit/MemoryManager.h"
//#include "crossbit/TraceManager.h"
//#include "crossbit/Interpreter.h"
//#include "crossbit/Translator.h"
//#include "crossbit/TBlock.h"
//#include "crossbit/TCache.h"
//#include "crossbit/VBlockBuilder.h"
//#include "crossbit/VFilter.h"
//#include "crossbit/SYSCALL.h"
//#include "crossbit/SyscallHandler.h"
//#include "crossbit/ProcessorState.h"
//#include <signal.h>


namespace crossbit {

    //class ProcessorState;
    //class MemoryImage;

    class SignalRegister
    {
        public:
            SignalRegister():signal_handler(0),
							rt_signal_handler(0),
							sigaction_handler(0),
							rt_sigaction_handler(0){}

			void setHandler(XTMemAddr sig_h, XTMemAddr rt_sig_h, XTMemAddr sigaction_h, XTMemAddr rt_sigaction_h)
			{
				signal_handler = sig_h;
				rt_signal_handler = rt_sig_h;
				sigaction_handler = sigaction_h;
				rt_sigaction_handler = rt_sigaction_h;
			}

			virtual XTInt32 regSignalHandler(XTInt32 src_sig_num, XTMemAddr src_sig_h) {}
			virtual XTInt32 regRTSignalHandler(XTInt32 src_sig_num, XTMemAddr src_rt_sig_h) {}
			virtual XTInt32 regSigactionHandler(XTInt32 src_sig_num, XTMemAddr src_act, XTMemAddr src_oldact) {}
			virtual XTInt32 regRTSigactionHandler(XTInt32 src_sig_num, XTMemAddr src_act, XTMemAddr src_oldact) {}

			virtual XTInt32	convertSigNum2Host(XTInt32 src_sig_num) {}
			virtual XTUint32 convertSaFlags2Host(XTUint32 src_sa_flags) {}
			virtual XTInt32 convertSbHow2Host(XTInt32 src_sb_how) {}
			virtual	void convertSaMask2Host(XTUint32 *src_sa_mask, XTUint32 *local_sa_make) {}	//On different platform, signal number is different.
																								//So mask bits is different also.
																								//x86 is 64 bits, mips is 128 bits

			virtual void setHandlerSPC(XTInt32 scr_sig_num, XTMemAddr handler_SPC) {}
			virtual XTMemAddr getHandlerSPC(XTInt32 scr_sig_num) {}
            virtual ~SignalRegister() {} 

        protected:
			XTMemAddr	signal_handler;
			XTMemAddr	rt_signal_handler;
			XTMemAddr	sigaction_handler;
			XTMemAddr	rt_sigaction_handler;

		private:
			SignalRegister& operator=(SignalRegister&);
			SignalRegister(SignalRegister&);
    };
}
#endif
